<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%sys_users}}".
 *
 * @property integer $id
 * @property string $phone
 * @property string $parent_phone
 * @property integer $type
 * @property string $password
 * @property integer $role
 * @property integer $last_login_time
 * @property string $truename
 * @property string $qq
 * @property string $email
 * @property string $weixin
 * @property string $tel
 * @property string $company_name
 * @property string $company_addr
 * @property string $company_regnum
 * @property string $company_range
 * @property string $company_spec_range
 * @property string $company_type
 * @property string $company_est_time
 * @property string $company_licence
 * @property integer $reg_time
 * @property integer $status
 */
class Users extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%sys_users}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['phone', 'password'], 'required'],
            [['type', 'role', 'last_login_time', 'reg_time', 'status'], 'integer'],
            [['phone', 'parent_phone'], 'string', 'max' => 11],
            [['password'], 'string', 'max' => 120],
            [['truename', 'qq', 'tel', 'company_type'], 'string', 'max' => 20],
            [['email', 'weixin'], 'string', 'max' => 50],
            [['company_name', 'company_regnum'], 'string', 'max' => 40],
            [['company_addr', 'company_licence'], 'string', 'max' => 100],
            [['company_range', 'company_spec_range', 'company_est_time'], 'string', 'max' => 500]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'phone' => 'Phone',
            'parent_phone' => 'Parent Phone',
            'type' => 'Type',
            'password' => 'Password',
            'role' => 'Role',
            'last_login_time' => 'Last Login Time',
            'truename' => 'Truename',
            'qq' => 'Qq',
            'email' => 'Email',
            'weixin' => 'Weixin',
            'tel' => 'Tel',
            'company_name' => 'Company Name',
            'company_addr' => 'Company Addr',
            'company_regnum' => 'Company Regnum',
            'company_range' => 'Company Range',
            'company_spec_range' => 'Company Spec Range',
            'company_type' => 'Company Type',
            'company_est_time' => 'Company Est Time',
            'company_licence' => 'Company Licence',
            'reg_time' => 'Reg Time',
            'status' => 'Status',
        ];
    }
       public static function getCompanyname($params) {   
            
           $res = Users::findOne([ 'id' => $params]); 
//           echo $res['company_name'];
//           //var_dump($res);
//           die();
           $temp = $res->attributes['company_name'];         
           return $temp;
    }
}